<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="zhcms.admin.*" %> 
<%@ page import="zhcms.framework.*" %> 
<%@ include file="include/adminhead.jsp" %>
<%
request.setCharacterEncoding("utf-8");
String action=request.getParameter("atcion");
GyUserLoginValidate gycheck=new GyUserLoginValidate();
int ischeck=gycheck.UserLoginValidate(request, response);
if(ischeck==0)
{
		try{
			out.println("<script language='javascript'>alert('对不起！，您还没有登陆');location.href=\"index.jsp\";</script>");
		}
		catch(Exception e){
			e.printStackTrace();
		}
} 

%>
<TABLE width="100%" border=0 align="center" cellPadding=0 cellSpacing=0 class=sortbutton>
	<tr> 
	    <th width="100%" height="22" valign="middle"><a href="?">管理首页</a> | <a href="?atcion=add">新增</a>  </th>
	</tr>
</table>
<br>
<% 
if(action==null || action.length()<=0  || action.equals("main"))
{
String page1=request.getParameter("p");
int pageb;    //存储当前页码
if(page1==null)
   pageb=1;
else 
   pageb=Integer.parseInt(page1);
  
GyPlus gyf=new GyPlus();

int countnum=gyf.listcount();
%>
<table width="98%" border="0" cellpadding="0" cellspacing="0" align="center" class="TableBorder">
  <tr valign="middle" align="center" height="22"> 
    <th class=sort width="10%">ID</th>
    <th class=sort width="15%">插件名称</th>
    <th class=sort width="15%">插件描述</th>
    <th class=sort width="15%">jar包</th>
    <th class=sort width="15%">作者</th>
    <th class=sort width="10%">状态</th>
    <th class=sort width="20%">操作</th>
  </tr>
<%
if(countnum>0)
{
String lybpages="";
ArrayList<HashMap<String, String>> gytInFor;
gytInFor=new ArrayList<HashMap<String, String>>();
gytInFor=gyf.getAllList(pageb);
lybpages=gyf.getPageStr();
for(int i=0;i<gytInFor.size();i++)
{
	Map<String,String> iAdmininfo=new HashMap<String,String>();
	iAdmininfo =gytInFor.get(i);
 %>
  <tr valign="middle" bgcolor="#FFFFFF" align="center" height="22"> 
    <td>&nbsp;<%=iAdmininfo.get("id")%></td>
    <td align="left">&nbsp;<%=iAdmininfo.get("name")%></td>
    <td>&nbsp;<%=iAdmininfo.get("description")%></td>
    <td><%=iAdmininfo.get("jarurl")%></td>
    <td><%=iAdmininfo.get("author")%></td>
    <td><%=iAdmininfo.get("isok")%></td>
    <td><a href="?atcion=add&postid=<%=iAdmininfo.get("id")%>">编辑</a> | <a href="/zhcms!admin!GyPlus(del).do?postid=<%=iAdmininfo.get("id")%>" onclick="{if(confirm('确定删除吗?')){return true;}return false;}">删除</a></td>
  </tr>
<%
}
 %>
  <tr valign="middle" bgcolor="#FFFFFF" align="right">
	<td colspan="7" height="22">&nbsp;<%=lybpages%></td>
  </tr>
 <%
 }
 else
 {
 %> <tr valign="middle" bgcolor="#FFFFFF">
	<td colspan="7" height="22">&nbsp;暂时没有任何信息！</td>
  </tr>
 <%
 } 
 %>
</table>
<%
}
else if(action.equals("add")) 
{

String postid=request.getParameter("postid");

String name="";
String description="";
String jarclasstruepath="";
String jarurl="";
String classname="";
String ismanager="";
String managerurl="";
String managername="";
String isbaohan="";
String isok="";
String author="";

if(postid==null || postid.length()<=0)
{
	
}
else
{
	GyPlus gyfk=new GyPlus();
	ArrayList<HashMap<String, String>> gytFkOne;
	gytFkOne=new ArrayList<HashMap<String, String>>();
	gytFkOne=gyfk.getOneList(postid);
	if(gytFkOne.size()>0)
	{
		Map<String,String> iiFriendLinkinfo=new HashMap<String,String>();
		iiFriendLinkinfo=gytFkOne.get(0);
		name=iiFriendLinkinfo.get("name");
		description=iiFriendLinkinfo.get("description");
		jarclasstruepath=iiFriendLinkinfo.get("jarclasstruepath");
		jarurl=iiFriendLinkinfo.get("jarurl");
		classname=iiFriendLinkinfo.get("classname");
		ismanager=iiFriendLinkinfo.get("ismanager");
		
		
		managerurl=iiFriendLinkinfo.get("managerurl");
		managername=iiFriendLinkinfo.get("managername");
		isbaohan=iiFriendLinkinfo.get("isbaohan");
		isok=iiFriendLinkinfo.get("isok");
		author=iiFriendLinkinfo.get("author");
	}
	
}

%>
<table width="80%" border="0" cellpadding="0" cellspacing="0" class=TableBorder align="center">
  <form name=a1  method="post" action="/zhcms!admin!GyPlus(save).do?postid=<%=postid%>">
    <tr align="center" valign="middle"> 
      <th colspan="2" height="22">插件管理</th>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="20%" align="center">插件名称</td>
      <td align="left">&nbsp;<input type="text" name="name" size="30" value="<%=name%>"></td>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="20%" align="center">插件描述</td>
      <td align="left">&nbsp;<input type="text" name="description" size="30" value="<%=description%>"></td>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="20%" align="center">jar包名称</td>
      <td align="left">&nbsp;<input type="text" name="jarurl" size="40" value="<%=jarurl%>"></td>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="20%" align="center">类的全称</td>
      <td align="left">&nbsp;<input type="text" name="classname" size="40" value="<%=classname%>"></td>
    </tr>
    
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="20%" align="center">是否有后台管理</td>
      <td align="left">&nbsp;<select name="ismanager">
        <option value="1" <%
        						if(ismanager.equals("1"))
        									{
        										out.println(" selected ");
        									}
        		 %>>有</option>
      	 <option value="0" <%
        						if(ismanager.equals("0"))
        									{
        										out.println(" selected ");
        									}
        		 %>>无 </option>
        </select></td>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="20%" align="center">后台管理地址</td>
      <td align="left">&nbsp;<input type="text" name="managerurl" size="40" value="<%=managerurl%>"></td>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="20%" align="center">插件后台名称</td>
      <td align="left">&nbsp;<input type="text" name="managername" size="30" value="<%=managername%>"></td>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="20%" align="center">是否有前台调用</td>
      <td align="left">&nbsp;<select name="isbaohan">
        <option value="1" <%
        						if(isbaohan.equals("1"))
        									{
        										out.println(" selected ");
        									}
        		 %>>有</option>
      	 <option value="0" <%
        						if(isbaohan.equals("0"))
        									{
        										out.println(" selected ");
        									}
        		 %>>无 </option>
        </select></td>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="20%" align="center">是否启用</td>
      <td align="left">&nbsp;<select name="isok">
        <option value="1" <%
        						if(isok.equals("1"))
        									{
        										out.println(" selected ");
        									}
        		 %>>启用</option>
      	 <option value="0" <%
        						if(isok.equals("0"))
        									{
        										out.println(" selected ");
        									}
        		 %>>停止</option>
        </select></td>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="20%" align="center">作者</td>
      <td align="left">&nbsp;<input type="text" name="author" size="40" value="<%=author%>"></td>
    </tr>

    <tr bgcolor="#FFFFFF"> 
      <td align="center" valign="middle" colspan="2"><input type="submit" name="Submit" value="更新">&nbsp;<input type="reset" name="Submit2" value="重置"></td>
    </tr>
  </form>
</table>
<%
}
%>
<%@ include file="include/adminfoot.jsp" %>